package com.yang.community.entity;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;

@Data
// es配置  索引 类型(这个随意因为相当于是占位符已经半废弃了) 分片 副本
@Document(indexName = "discusspost", type = "_doc", shards = 6, replicas = 3)
public class DiscussPost {
    @Id
    private Integer id;
    @Field(type = FieldType.Integer)
    private int userId;
                                  // 存储解析器，搜索解析器 保存的时候通过解析器将保存的内容拆分为多个词条产生多个索引与之匹配 增加搜索范围、
                                  // ik_max_work 是ik中一个最大范围的拆分解析器  搜索的时候使用聪明一点的,尽可能少一点结果的(精准)
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String title;
    // 被搜索的字段都要这样配置
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String content;

    @Field(type = FieldType.Integer)
    private Integer type;

    @Field(type = FieldType.Integer)
    private Integer status;

    @Field(type = FieldType.Date)
    private Date createTime;

    @Field(type = FieldType.Double)
    private Double score;

    @Field(type = FieldType.Integer)
    private Integer commentCount;


    @Override
    public String toString() {
        return "DiscussPost{" +
                "id=" + id +
                ", userId='" + userId + '\'' +
                ", title='" + title + '\'' +
                ", type=" + type +
                ", status=" + status +
                ", createTime=" + createTime +
                ", commentCount=" + commentCount +
                ", score=" + score +
                ", content='" + content + '\'' +
                '}';
    }
}
